<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [formGroup]="formGroup" class="formGroup" lvKeepRequiredWidth>
    <lv-form-item>
        <lv-form-label>
            {{ 'common_bindwidth_label' | i18n }}
        </lv-form-label>
        <lv-form-control>
            <lv-switch formControlName='bindWidthStatus' class="mount-bindWidth"></lv-switch>
            <div *ngIf="formGroup.value.bindWidthStatus" class="checkbox-container">
                <lv-form-item>
                    <lv-form-label>
                        <label lv-checkbox formControlName="bindWidthMin"
                            (ngModelChange)="bindWidthMinChange($event)">{{'explore_min_label' | i18n}}</label>
                    </lv-form-label>
                    <lv-form-control [lvErrorTip]='minBandwidthErrorTip'>
                        <input lv-input type="text" formControlName="min_bandwidth" class="advanced-input-container"
                            placeholder="1~999999999" />&nbsp;MB/s
                    </lv-form-control>
                </lv-form-item>
                <lv-form-item>
                    <lv-form-label>
                        <label lv-checkbox formControlName="bindWidthMax"
                            (ngModelChange)="bindWidthMaxChange($event)">{{'explore_max_label' | i18n}}</label>
                    </lv-form-label>
                    <lv-form-control [lvErrorTip]='maxBandwidthErrorTip'>
                        <input lv-input type="text" formControlName="max_bandwidth" class="advanced-input-container"
                            placeholder="1~999999999" />&nbsp;MB/s
                    </lv-form-control>
                </lv-form-item>
                <lv-form-item
                    *ngIf="formGroup.value.max_bandwidth && formGroup.get('max_bandwidth').valid && formGroup.value.bindWidthMax">
                    <lv-form-label>
                        <label lv-checkbox formControlName="bindWidthBurst"
                            (ngModelChange)="bindWidthBurstChange($event)">{{'explore_burst_label' | i18n}}</label>
                    </lv-form-label>
                    <lv-form-control [lvErrorTip]='burstBandwidthErrorTip'>
                        <input lv-input type="text" formControlName="burst_bandwidth" class="advanced-input-container"
                            placeholder="1~999999999" />&nbsp;MB/s
                    </lv-form-control>
                </lv-form-item>
            </div>
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label>
            {{ 'protection_nor_iops_label' | i18n }}
        </lv-form-label>
        <lv-form-control>
            <lv-switch formControlName='iopsStatus'></lv-switch>
            <ng-container *ngIf="formGroup.value.iopsStatus">
                <div class="checkbox-container mgb-chekcbox">
                    <lv-form-item>
                        <lv-form-label>
                            <label lv-checkbox formControlName='iopsMin'
                                (ngModelChange)="iopsMinChange($event)">{{'explore_min_label' | i18n}}</label>
                        </lv-form-label>
                        <lv-form-control [lvErrorTip]='minIopsErrorTip'>
                            <input lv-input type="text" formControlName="min_iops" class="advanced-input-container"
                                placeholder="100~999999999" />
                        </lv-form-control>
                    </lv-form-item>
                    <lv-form-item>
                        <lv-form-label>
                            <label lv-checkbox formControlName='iopsMax'
                                (ngModelChange)="iopsMaxChange($event)">{{'explore_max_label' | i18n}}</label>
                        </lv-form-label>
                        <lv-form-control [lvErrorTip]='maxIopsErrorTip'>
                            <input lv-input type="text" formControlName="max_iops" class="advanced-input-container"
                                placeholder="100~999999999" />
                        </lv-form-control>
                    </lv-form-item>
                    <lv-form-item
                        *ngIf="formGroup.value.max_iops && formGroup.get('max_iops').valid && formGroup.value.iopsMax">
                        <lv-form-label>
                            <label lv-checkbox formControlName='iopsBurst'
                                (ngModelChange)="iopsBurstChange($event)">{{'explore_burst_label' | i18n}}</label>
                        </lv-form-label>
                        <lv-form-control [lvErrorTip]='burstIopsErrorTip'>
                            <input lv-input type="text" formControlName="burst_iops" class="advanced-input-container"
                                placeholder="100~999999999" />
                        </lv-form-control>
                    </lv-form-item>
                </div>
                <lv-collapse lvType="simple">
                    <lv-collapse-panel [lvTitle]="moreContentTpl" [lvExpanded]="false">
                        <lv-group lvGutter='32px'>
                            <lv-group lvDirection='vertical' lvGutter='16px'>
                                <span class="aui-text-desc">{{'explore_io_size_label' | i18n}}</span>
                                <span class="aui-text-desc">Min</span>
                                <span class="aui-text-desc">Max</span>
                                <span class="aui-text-desc">Burst</span>
                            </lv-group>
                            <lv-group *ngFor="let item of iopsItems" lvDirection='vertical' lvGutter='16px'>
                                <span>{{item.header}}</span>
                                <span>{{item.min | nil}}</span>
                                <span>{{item.max | nil}}</span>
                                <span>{{item.burst | nil}}</span>
                            </lv-group>
                        </lv-group>
                    </lv-collapse-panel>
                </lv-collapse>
            </ng-container>
        </lv-form-control>
    </lv-form-item>
    <ng-container
        *ngIf="(formGroup.value.iopsStatus && formGroup.value.burst_iops && formGroup.value.iopsBurst) || (formGroup.value.bindWidthStatus && formGroup.value.burst_bandwidth && formGroup.value.bindWidthBurst)">
        <lv-form-item>
            <lv-form-label lvRequired> {{'explore_max_burst_label' | i18n}}</lv-form-label>
            <lv-form-control [lvErrorTip]='burstTimeErrorTip'>
                <input lv-input type="text" formControlName="burst_time" class="advanced-input-container"
                    placeholder="1~999999999" />
                <i lv-icon="aui-icon-help" lv-tooltip="{{'explore_max_burst_desc_label' | i18n}}"
                    class="configform-constraint" lvColorState='true'></i>
            </lv-form-control>
        </lv-form-item>
    </ng-container>
    <lv-form-item>
        <lv-form-label> {{'protection_nor_latency_label' | i18n}}</lv-form-label>
        <lv-form-control>
            <lv-switch formControlName='latencyStatus'></lv-switch>
            <ng-container *ngIf="formGroup.value.latencyStatus">
                <div class="checkbox-container mgb-10">
                    <lv-form-item>
                        <lv-form-label>
                            <span class="aui-text-help-sm">
                                {{'explore_max_label' | i18n}}
                            </span>
                        </lv-form-label>
                        <lv-form-control [lvErrorTip]="baseUtilService.requiredErrorTip">
                            <lv-radio-group formControlName="latency">
                                <lv-group [lvGutter]="'14px'">
                                    <lv-radio [lvValue]="dataMap.LiveMount_Latency.zeroDotsFive.value">
                                        {{dataMap.LiveMount_Latency.zeroDotsFive.label}}
                                    </lv-radio>
                                    <lv-radio [lvValue]="dataMap.LiveMount_Latency.oneDotsFive.value">
                                        {{dataMap.LiveMount_Latency.oneDotsFive.label}}
                                    </lv-radio>
                                </lv-group>
                            </lv-radio-group>
                        </lv-form-control>
                    </lv-form-item>
                </div>
                <lv-collapse lvType="simple">
                    <lv-collapse-panel [lvTitle]="moreContentTpl" [lvExpanded]="false">
                        <lv-group lvGutter='32px'>
                            <lv-group lvDirection='vertical' lvGutter='16px'>
                                <span class="aui-text-desc">{{'explore_io_size_label' | i18n}}</span>
                                <span class="aui-text-desc">Max</span>
                            </lv-group>
                            <lv-group *ngFor="let item of latencyItems" lvDirection='vertical' lvGutter='16px'>
                                <span>{{item.header}}</span>
                                <span>{{item.max | nil}}</span>
                            </lv-group>
                        </lv-group>
                    </lv-collapse-panel>
                </lv-collapse>
            </ng-container>
        </lv-form-control>
    </lv-form-item>
</lv-form>
<ng-template #moreContentTpl>
    <span class="aui-link">{{'protection_other_block_size_label' | i18n}}</span>
</ng-template>
